Paradigms : Sorting
نویسنده
چکیده
Hi folks. A strong and unique point of BLUe's format system is its indexing on the fly. Be it for a total document or just for a chapter. One of the requisites for indexing on the fly is the possibility to sort within T E X. Sorting has always been an important topic in computer science. In T E X I needed sorting on several occasions especially for sorting numbers such as citation lists, words such as addresses, and index entries. This note is devoted to paradigms encountered while implementing and applying sorting in T E X. Sorting can be characterized by-the set to be sorted (numbers, word. etc.)-the addressing of elements of the set-the ordering for the set-the comparison operation, and-the exchange operation. To do some sorting of your own please load from blue.tex the index macros via \loadindexmacros. Below parts have been extracted from that collection of macros to make this note as intelligible as possible. \ea is my shortcut for \expandafter. A simple sorting method is repeatedly searching for the smallest element. In the example below the set is defined as a def with list element tag \\. \def\lst{\\\ia\\\ib\\\ic} \def\ia{314} \def\ib{1} \def\ic{27} % \def\dblbsl#1{\ifnum#1<\min\let\min=#1\fi} % \loop\ifx\empty\lst\expandafter\break\fi \def\\{\let\\=\dblbsl\let\min=} %space \lst%find minimum \min%typeset minimum {\def\\#1{\ifx#1\min \else\nx\\% \nx#1\fi}\xdef\lst{\lst}}% \pool%Inspired upon van der Goot's %Midnight macros. \def\loop#1\pool{#1\loop#1\pool} \def\break#1\pool{} The coding implements the looping of the basic steps-find minimum (via \lst, and suitable definition of DeK's list element tag \\)-typeset minimum (via \min)-delete minimum from the list (via another appropriate definition of the list element tag, and the use of \xdef. Remark. The kludge for using \ifx instead of \ifnum in the deletion part is necessary because T E X inserts a \relax. If we adopt array addressing in T E X for the elements to be sorted then we can implement bubble sort in T E X too. When we think of associating values to (index) numbers— 1 → \value{1} —then we are talking about an array. A mapping of the natural numbers on. .. for example the natural numbers. The \value control sequence can be implemented as follows. \def\value#1{\csname#1\endcsname} The writing to the array elements can be done via \def\1{} \def\2{}... In general this must be done via \ea\def\csname\endcsname{} 3.1.1 To get the hang of it The reader must be aware of the differences between-the index number, k-the counter variable \k, with the value k as index number-the control sequences …
منابع مشابه
An Empirical Investigation of Collateral and Sorting in the HELOC Market
This research explores the role that collateral plays in sorting borrowers according to risk classes in the secured credit market. Two distinct paradigms exist in the commercial loan market literature on risk-sorting based on collateral: (a) the sorting-by-observed-risk paradigm, which predicts a positive association between collateral and borrower risk; and (b) the sorting-by-private-informati...
متن کاملEfficient Parallel Algorithms for Optical Computing with the DFT Primitive
The optical computing technology ooers new challenges to the algorithm designers since it can perform an n-point DFT computation in only unit time. Note that DFT is a non-trivial computation in the PRAM model. We develop two new models, DFT-VLSIO and DFT-Circuit, to capture this characteristic of optical computing. We also provide two paradigms for developing parallel algorithms in these models...
متن کاملAlgorithms and Data Structures for External Memory
Data sets in large applications are often too massive to fit completely inside the computer’s internal memory. The resulting input/output communication (or I/O) between fast internal memory and slower external memory (such as disks) can be a major performance bottleneck. In this work we survey the state of the art in the design and analysis of algorithms and data structures for external memory ...
متن کاملName Matching v . s . Structure Matching in Typing Systems for the
In the literature, there have been intensive studies on typing (sorting) systems for the polyadic -calculus, originated by Milner's sorting discipline [10] based on name matching. The proposed systems, so far, are categorized into the two groups | systems by name matching and ones by structure matching (possibly with subtyping) | and obtain similar results. A natural question arises \Is there a...
متن کاملEmpirical approaches to metacommunities: a review and comparison with theory.
Metacommunity theory has advanced understanding of how spatial dynamics and local interactions shape community structure and biodiversity. Here, we review empirical approaches to metacommunities, both observational and experimental, pertaining to how well they relate to and test theoretical metacommunity paradigms and how well they capture the realities of natural ecosystems. First, we show tha...
متن کاملHardware Acceleration of Divide-and-Conquer Paradigms: a Case Study
We describe a method for speeding up divide-andconquer algorithms with a hardware coprocessor, using sorting as an example. The method employs a conventional processor for the “divide” and “merge” phases, while the “conquer” phase is handled by a purpose-built coprocessor. It is shown how transformation techniques from the Ruby language can be adopted in developing a family of systolic sorters,...
متن کامل